import request from "@/utils/request";
import { getToken, getUserId, getSiteId } from "@/utils/auth";

// 客户查询
export function customerQueryApi(params = {
  UserType: "",
  keyStr: "",
  Province: "",
  BrandName: "",
  OrderClerkName: "",
  SalesmanName: "",
  PageIndex: 1,
  PageSize: 10
}) {
  return request({
    url: "/CustomerQueryV3/GetOrderList",
    method: "get",
    params: {
      KeyStr: params.keyStr || '',
      UserType: params.UserType || '',
      Province: params.Province || '',
      BrandName: params.BrandName || '',
      OrderClerkName: params.OrderClerkName || '',
      SalesmanName: params.SalesmanName || '',
      AccessToken: getToken(),
      SiteId: getSiteId(),
      PageIndex: params.PageIndex || 1,
      PageSize: params.PageSize || 10
    },
  });
}

// 客户增改
export function customerUpdateApi(params = {
  UserName: "",
  Province: "",
  City: "",
  Country: "",
  UserId: 0,
}) {
  return request({
    url: "/CustomerAddV3/Post",
    method: "post",
    data: {
      UserId: params.UserId,
      UserName: params.UserName || '',
      Province: params.Province || '',
      City: params.City || '',
      Country: params.Country || '',
      SiteId: getSiteId(),
      AccessToken: getToken(),
    },
  });
}

// 接单员查询
export function orderTakerQueryApi(params = {
  keyStr: "",
  pageNum: 1,
  pageSize: 10
}) {
  return request({
    url: "/OrderClerkQueryV3/GetUserLst",
    method: "get",
    params: {
      KeyStr: params.keyStr,
      AccessToken: getToken(),
      SiteId: getSiteId(),
      PageIndex: params.pageNum,
      PageSize: params.pageSize
    },
  });
}
// 业务员查询
export function salesmanQueryApi(params = {
  keyStr: "",
  pageNum: 1,
  pageSize: 10
}) {
  return request({
    url: "/SalesmanQueryV3/GetUserLst",
    method: "get",
    params: {
      KeyStr: params.keyStr,
      AccessToken: getToken(),
      SiteId: getSiteId(),
      PageIndex: params.pageNum,
      PageSize: params.pageSize
    },
  });
}